<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改用户')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal" id="form-user-edit" >
            <input name="id"  type="hidden"  th:field="${job.id}" />
            
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">任务名：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="name" class="form-control" type="text" maxlength="30" th:field="${job.name}" required>
                            	<span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">Executor：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="executorName" class="form-control" type="text" maxlength="30" th:field="${job.executorName}" required>
                            	<span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">jobHandlerName：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="jobHandlerName" class="form-control" type="text" maxlength="30" th:field="${job.jobHandlerName}" required>
                            	<span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">优先级：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="priority" class="form-control" type="number" min="1" max="10" th:field="${job.priority}" required>
                            	<span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">重量：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="weight" class="form-control" type="number" min="1" max="5" th:field="${job.weight}" required>
                                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">执行超时时间ms：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="executeTimeout" class="form-control" type="number" min="1000" max="3600000" th:field="${job.executeTimeout}" required>
                                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">任务参数：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <textarea name="params" class="form-control" maxlength="65535" th:text="${job.jobDetail?.params}"></textarea>
                                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">任务描述：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <textarea name="desc" class="form-control" maxlength="200" th:text="${job.jobDetail?.desc}"></textarea>
                                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <span th:if="${job.type.toString() == 'Delay'}">
            <h4 class="form-header h4">delay任务信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">任务延迟ms：</label>
                        <div class="col-sm-8">
                            <input name="delay" placeholder="请输入delay" class="form-control" type="number" min="1000" max="31536000000000" th:value="${job.delayJob.delay}">
                        </div>
                    </div>
                </div>
                
            </div>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">ExecuteFailed重试次数：</label>
                        <div class="col-sm-8">
                            <input name="retryOnExecuteFailed" placeholder="请输入retryOnExecuteFailed" class="form-control" type="number" min="0" th:value="${job.delayJob.retryOnExecuteFailed}">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">ExecuteFailed重试回退ms：</label>
                        <div class="col-sm-8">
                            <input name="retryBackoffOnExecuteFailed" placeholder="请输入retryBackoffOnExecuteFailed" class="form-control" type="number" min="1000" th:value="${job.delayJob.retryBackoffOnExecuteFailed}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">NoQualified重试次数：</label>
                        <div class="col-sm-8">
                            <input name="retryOnNoQualified" placeholder="请输入retryOnNoQualified" class="form-control" type="number" min="0" th:value="${job.delayJob.retryOnNoQualified}">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">NoQualified重试回退ms：</label>
                        <div class="col-sm-8">
                            <input name="retryBackoffOnNoQualified" placeholder="请输入retryBackoffOnNoQualified" class="form-control" type="number" min="1000" th:value="${job.delayJob.retryBackoffOnNoQualified}">
                        </div>
                    </div>
                </div>
            </div>
            </span>
            
            <span th:if="${job.type.toString() == 'Schedule'}">
            <h4 class="form-header h4">schedule任务信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">scheduleFixRate：</label>
                        <div class="col-sm-8">
                            <input name="scheduleFixRate" placeholder="请输入scheduleFixRate" class="form-control" type="number" min="1000" max="31536000000000" th:value="${job.scheduleJob?.scheduleFixRate}">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">scheduleFixDelay：</label>
                        <div class="col-sm-8">
                            <input name="scheduleFixDelay" placeholder="请输入scheduleFixDelay" class="form-control" type="number" min="1000" max="31536000000000" th:value="${job.scheduleJob.scheduleFixDelay}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">sheduleCron：</label>
                        <div class="col-sm-8">
                            <input name="sheduleCron" placeholder="请输入sheduleCron" class="form-control" type="text" th:value="${job.scheduleJob.sheduleCron}">
                        </div>
                    </div>
                </div>
            </div>
            </span>
            
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "api/job";
        
        $("#form-user-edit").validate({
        	onkeyup: false,
        	rules:{
        		
        	},
        	messages: {
        		"email": {
                    remote: "Email已经存在"
                },
        		"phonenumber":{
                	remote: "手机号码已经存在"
        		}
            },
            focusCleanup: true
        });
        
        function submitHandler() {
	        if ($.validate.form()) {
	        	var data = $("#form-user-edit").serializeArray();
// 	        	var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
// 	        	var roleIds = $.form.selectCheckeds("role");
// 	        	var postIds = $.form.selectSelects("post");
// 	        	data.push({"name": "status", "value": status});
// 	        	data.push({"name": "roleIds", "value": roleIds});
// 	        	data.push({"name": "postIds", "value": postIds});
	        	$.operate.saveTab(prefix + "/update", data);
	        }
	    }

        /* 用户管理-修改-选择部门树 */
        function selectDeptTree() {
        	var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
		    var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			var body = $.modal.getChildFrame(index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			$.modal.close(index);
		}

		$(function() {
            $('#post').select2({
                placeholder: "请选择岗位",
                allowClear: true
            });
        })
    </script>
</body>
</html>